// 使用class关键字来定义一个类

/** 
 * 对象中主要包含了两个部分
 * 属性
 * 方法
 * 
  */
/* class Person {
    name:string = 'xiaohua'
    sex = '女'
    static age:number = 111
}

const per = new Person()
console.log(per)
console.log(per.name)
per.name = 'wuwu'
console.log(per.name)
Person.age = 456
console.log(Person.age) */

class Dog {
    name:string;
    age:number;
    // constructor 构造函数
    constructor(name:string,age:number) {
        console.log(age)
        this.age = age
        this.name = name
    }
    demo() {
        return this
    }
}
// 调用 new 相当于在调用构造函数
const dog = new Dog('胡',123)
const dog1 = new Dog('花',456)

console.log(dog)

// apply修改this指向
console.log(dog.demo.apply({}))